﻿@model WorldArtPrice.Models.ArtistSearchResultModel
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script>
    function ShowAdvance()
    {
        $('#divAdvanceSearch').show();
    }
    function HideAdvance() {
        $('#divAdvanceSearch').hide();
    }
</script>
@using (Html.BeginForm("Index", "Artist", FormMethod.Post))
{
    @Html.AntiForgeryToken() 
    @Html.ValidationSummary(true) 
<div id="results"> 
    <div class="results-controls" id="results-controls-1">
        <div id="results_filters">                                                                
            <div style="float: left; margin-top: 5px;">
                @(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Now.Month).ToUpper() +" "+ DateTime.Now.Year)
            </div>
            <div style="float: right;">   
                                                  
                    @Html.LabelFor(m => m.ArtistsName1, new { @class="results_filters_label"})
                    @Html.TextBoxFor(m => m.ArtistsName1, new { @class="text placeholder"})
                    <input value="" name="searchSubmit" class="headerSearchSubmit" id="headerSearchSubmit" type="submit">
                    <a href="javascript:ShowAdvance()">Advance Search</a>                    
                
            </div> 
            
        </div>
        <div class="clearer">
        </div>
        <div class="results-range" style="display:none;border: 1px solid rgb(117, 117, 117); margin-top: 10px; margin-left: 10px; width: 659px; margin-bottom: 10px;" id="divAdvanceSearch" >
                                    
                    <table width="100%" cellspacing="0" cellpadding="0" border="0" id="table5">    
                        <tr>
                            <td valign="top" align="left">                        
                                <h4 style="margin-bottom: 10px; font-size:16px">
                                    Enter what you see:<br>                            
                                    Enter all or part of an artist’s name in the search field. You can use wildcards
                                    if you are in doubt about the spelling.
                                </h4> 
                                <p style="margin-top: 0px; margin-bottom: 10px; padding-left: 0px;">                       
                                    &nbsp;&nbsp;&nbsp; ‘+’ replaces a single letter&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;
                                    ‘*’ replaces several letters
                                <br />
                                    &nbsp;&nbsp;&nbsp; You can enter the artist’s dates and/or country for a more refined search.  
                                </p>         
                                <table width="100%" cellspacing="0" cellpadding="5" border="0" id="table6">
                                    <tr>
                                        <td width="25%"><b style="font-size:16px">@Html.LabelFor(m=>m.ArtistsName2)</b></td>
                                        <td width="75%">
                                            @Html.TextBoxFor(m=>m.ArtistsName2)                                                                                       
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><b style="font-size:16px">@Html.LabelFor(m=>m.Born)</b>
                                        </td>
                                        <td>
                                            @Html.TextBoxFor(m => m.Born, new { @onkeypress = "if(event.keyCode==13){} else {if (event.keyCode < 48 || event.keyCode > 57){ event.returnValue = false;}}", @maxlength="4", @size="5", @value="" })
                                            &nbsp; (year, e.g. 1825)                                                                                                                                 
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><b style="font-size:16px">@Html.LabelFor(m=>m.Died)</b>
                                        </td>
                                        <td>
                                            @Html.TextBoxFor(m=>m.Died, new { @onkeypress = "if(event.keyCode==13){} else {if (event.keyCode < 48 || event.keyCode > 57){ event.returnValue = false;}}", @maxlength="4", @size="5", @value="" })
                                            &nbsp; (year, e.g. 1865)                                                                                                                                                                           
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><b style="font-size:16px">@Html.LabelFor(m=>m.CountryId)</b></td>
                                        <td>
                                            @Html.DropDownListFor(m => m.CountryId, new SelectList(Model.ListCoutry, "Id", "Country"))
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                        <td>
                                            <br>                                        
                                            <input type="submit" value="Search" id="send" class="knap" onmouseout="co(this,'out');" onmouseover="co(this,'in');" name="Action">
                                            &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:HideAdvance()" style="font-size:16px">Close</a>
                                        </td>
                                    </tr>
                                </table>            
                            </td>
                        </tr>
                    </table>
                              
            </div> 
        @Html.ValidationMessage("ArtistsName", new { style="color:#CC0000"})        
        @Html.ValidationMessage("Born", new { style="color:#CC0000"}) 
        @Html.ValidationMessage("Died", new { style="color:#CC0000"}) 
        <div class="clearer">
        </div>                            
        <div class="results-range">
            <b>Find artist </b>@(!string.IsNullOrEmpty(Model.KeyWord)? '"'+ Model.KeyWord +'"':"")<br />
            @Model.TotalRecord auctions found
        </div>
        <div class="clearer">
        </div>    
    </div>
    <!-- #results-controls-1 -->
    <div class="clearer">
    </div>
    <ul id="list-items">
        @foreach(var item in Model.ListArtists)
        {
            <li class="" id="day-19">
                <div class="auction-date">
                    <span class="month">@System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(item.AuctionTime.Month).Substring(0,3).ToUpper()</span>
                    <span class="date">@item.AuctionTime.Day</span>
                    <span class="year">@item.AuctionTime.Year</span>
                </div>
                <div class="auction-info">                    
                    <span class="location">ArtWord: @item.CountArtWord - Price: @item.CountPrice</span>
                    <div class="clearer"></div>
                    <p class="description">     
                        @{string action="GetByArtist/1/"+ @item.ArtistId + "/" + @CommandLib.Utils.UnicodeToKoDauAndGach(HttpUtility.HtmlDecode(item.FullName)) +".html";}                   
                        @Html.ActionLink(HttpUtility.HtmlDecode(string.IsNullOrEmpty(item.FullName)?"Unknown":item.FullName), action, "Price", null , new { @class="description" })
                    </p>
                    <ul class="auction-links">
                        <li>
                            <a href="#">@((item.Born == 0 ? "Born unknown" : item.Born.ToString()) + " - " + (item.Died == 0 ? "Die unknown" : item.Died.ToString()))</a>  (@item.Country)                          
                        </li>
                    </ul>
                </div>
                <div class="clearer"></div>
            </li>
        }
    </ul>
    <div class="results-nav" id="results-nav">                
        <div id="divPager" style="width: 100% !important; min-height: 0px !important; text-align: center; margin-left: 0px;">   
            <span style="float:left">
            Results
            @((Model.PageIndex-1)*30 + 1)
            &nbsp;-&nbsp;
            @((Model.PageIndex*30) < Model.TotalRecord ? (Model.PageIndex*30) : Model.TotalRecord)
            &nbsp;of&nbsp;@Model.TotalRecord
            </span>
            <span style="text-align:center">                                 
                @{                                        
                    int totalPage = Convert.ToInt32(Model.TotalRecord) % 30 == 0 ? Convert.ToInt32(Model.TotalRecord) / 30 : (Convert.ToInt32(Model.TotalRecord) / 30) + 1;
                    int pageIndex = Convert.ToInt32(Model.PageIndex);
                }
                @if (totalPage > 1)
                {
                    if (pageIndex > 1)
                    {                      
                        @Html.ActionLink("<<", "Index", "Artist", new { keyword = Server.UrlEncode(Model.KeyWord), born=Model.Born, died = Model.Died, country = Model.CountryId, pageIndex = 1 }, new { style = "margin-left:10px;color:#6C6C6C; text-decoration: none;" })
                        @Html.ActionLink("<", "Index", "Artist", new { keyword = Server.UrlEncode(Model.KeyWord), born=Model.Born, died = Model.Died, country = Model.CountryId, pageIndex = pageIndex-1 }, new { style = "margin-left:10px;color:#6C6C6C; text-decoration: none;" }) 
                    }                                        
                    var startPoint = (totalPage < 15) ? 1 : ((pageIndex > 14) ? pageIndex - 13 : 1);
                    var endPoint = (totalPage < 15) ? totalPage : ((pageIndex > 14) ? pageIndex : 14);
                    for (var page = startPoint; page <= endPoint; page++) {
                        if (page == pageIndex) {                                                                
                            @Html.ActionLink(page.ToString(), "Index", "Artist", new { keyword = Server.UrlEncode(Model.KeyWord), born=Model.Born, died = Model.Died, country = Model.CountryId, pageIndex = page }, new { style = "color: #000000;margin-left:10px;" }) 
                        }
                        else {                                                                
                            @Html.ActionLink(page.ToString(), "Index", "Artist", new { keyword = Server.UrlEncode(Model.KeyWord), born=Model.Born, died = Model.Died, country = Model.CountryId, pageIndex = page }, new { style = "margin-left:10px;color:#6C6C6C; text-decoration: none;" })
                        }
                    }
                    if (pageIndex < totalPage) {                                                                                                            
                        @Html.ActionLink(">", "Index", "Artist", new { keyword = Server.UrlEncode(Model.KeyWord), born=Model.Born, died = Model.Died, country = Model.CountryId, pageIndex = pageIndex + 1 }, new { style = "margin-left:10px;color:#6C6C6C; text-decoration: none;" })
                        @Html.ActionLink(">>", "Index", "Artist", new { keyword = Server.UrlEncode(Model.KeyWord), born=Model.Born, died = Model.Died, country = Model.CountryId, pageIndex = totalPage }, new { style = "margin-left:10px;color:#6C6C6C; text-decoration: none;" })
                    }
                }     
            </span>   
        </div>
    </div>
    <div class="clearer">
    </div>
    <!-- #results-controls-2 -->
    <div class="bottom-note">
        If you do not find the specific auction results you are interested in, please call
        our automated service at +1 212 703 8080 (New York) or +44 (0)20 7627 2707 (London).
    </div>
    <br>
</div>
}
